package mx.com.sinformex.simbel.pages;

import mx.com.sinformex.simbel.db.dao.IAdminDataAccess;
import mx.com.sinformex.simbel.utils.Session;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

/**
 * @author Oscar Ivan Hernandez Ventura [ oscar at sinformex dot com dot mx]
 *
 * @version $ Id : AdminPage.java , v 1.0 10/05/2009 angellore $
 */
public class BasicPage {
	
	@Inject
	private IAdminDataAccess adminDataAccess;
	@ApplicationState
	private Session session;

	private String error;
	private String alert;
	@InjectPage
	private Index index;
	
	@SetupRender
	Object validateSession() {
		if(session == null) {
			return index;
		}
		if(session.getUser() == null) {
			return index;
		}
		return null;
	}

	public IAdminDataAccess getAdminDataAccess() {
		return adminDataAccess;
	}

	public void setAdminDataAccess(IAdminDataAccess adminDataAccess) {
		this.adminDataAccess = adminDataAccess;
	}

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getAlert() {
		return alert;
	}

	public void setAlert(String alert) {
		this.alert = alert;
	}
	
	public boolean getHasError() {
		return error != null;
	}
	
	
}
